﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<QianBuo.Lottery.Web.Models.User.AllChildModel>" %>
<%@ Import Namespace="Code.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	全部会员
    <%TempData["Surrogate_AllChild.Where.Type"] = Request["Where.Type"]; %>
</asp:Content>


<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<div>
    <% Html.BeginForm(); %>
        <table class="table" width="100%">
            <tr class="th">
                <th colspan="4" align="left">&nbsp;&nbsp;搜索条件</th>
            </tr>
            <tr>
                <td>
                    <%=Html.LabelFor(p => p.Where.ChildName)%>
                    <%= Html.TextBoxFor(p => p.Where.ChildName, new { @class = "text100" })%>
                </td>
                <td>
                    <%=Html.LabelFor(p => p.Where.StartTime)%>：从
                    <%=Html.TextBoxFor(p => p.Where.StartTime, new { @class = "text100", onClick = "WdatePicker()" })%>
                    <%=Html.ValidationMessageFor(p=>p.Where.StartTime) %>
                </td>
                <td>
                    到
                    <%= Html.TextBoxFor(p => p.Where.EndTime, new { @class = "text100", onClick = "WdatePicker()" })%>
                    <%=Html.ValidationMessageFor(p=>p.Where.EndTime) %>
                </td>
                <td rowspan='2'>
                    <input type="submit" value="查找" />
                </td>
            </tr>
            <tr>
                <td>
                   <%-- <%=Html.LabelFor(p => p.Where.State) %>
                    <select id="State" name="Where.State">
                        <option value="0">全部</option>
                        <option value='<%=(int)Code.Models.UserOnlineState.OnLine%>' <%=(Model.Where!=null&&Model.Where.State==Code.Models.UserOnlineState.OnLine)?"Selected='selected'":"" %>>在线</option>
                        <option value="<%=(int)Code.Models.UserOnlineState.DowLine %>" <%=(Model.Where!=null&&Model.Where.State==Code.Models.UserOnlineState.DowLine)?"Selected='selected'":"" %>>离线</option>
                    </select>--%>
                </td>
                <td>
                    <%=Html.LabelFor(p => p.Where.MinMoney)%>：从
                    <%=Html.TextBoxFor(p => p.Where.MinMoney, new { @class = "text100" })%>
                    <%=Html.ValidationMessageFor(p=>p.Where.MinMoney) %>
                </td>
                <td>
                    到
                    <%=Html.TextBoxFor(p => p.Where.MaxMoney, new { @class = "text100" })%>
                    <%=Html.ValidationMessageFor(p=>p.Where.MaxMoney) %>
                </td>
            </tr>
        </table>
    <% Html.EndForm(); %>
    </div>
<div>
    <h4>所属:
    <%
        Model.Where = Model.Where ?? new QianBuo.Lottery.Web.Models.User.AllChild_Where();
        var user = Model.Parents.FirstOrDefault(p=>p.Uid==Model.LoginUserID);
        while (user!=null)
        {
            %><%=Html.ActionLink(user.LoginName + (user.Uid == Model.UserID ? string.Format("({0})", Model.ChildsCount) : ""), "AllChild", Url.Route(new { userID = user.Uid,Model.Where }), Url.Route(new {@class="a_blue" }))%>
            &nbsp;→&nbsp;<%
            user = Model.Parents.FirstOrDefault(p => p.CommandID == user.Uid);
        }
        %>
    </h4>
</div>
<div>
    <table class="table AllChild" width="100%">
        <tr class="th">
            <th>用户名</th><th>类型</th><th style=" width:50px;">余额</th><th>注册时间</th><th>最后登录时间</th><th>在线状态</th><th>方案</th><th>账变</th><th>用户状态</th><th>7天无账变</th>
        </tr>
        <% var i = 0;
           var urlLock = Url.Action("LockUser", "Surrogate");
           var urlFree = Url.Action("FreeUser", "Surrogate");
            foreach (var item in Model.Childs)
	    {%>
            <tr <%=i++%2==1?"class='supersede'":"" %>>
                <td align="left"><%= item.Type == (short)UserType.Surrogate ? Html.ActionLink(item.ChildName, "AllChild", Url.Route(new { page = 1, userID = item.Uid, Where = new { Model.Where.Type } }), Url.Route(new { @class = "a_blue" })) : Html.Label(item.ChildName)%></td>
                <td><%=Html.Label(((UserType)item.Type).GetName()) %></td>
                <td><%=item.Balance.ToString("F2") %></td>
                <td><%=Html.Label(item.RegistTime.ToString("yyyy-MM-dd HH:mm:ss")) %></td>
                <td><%=Html.Label(item.LastLoginTime.HasValue?item.LastLoginTime.Value.ToString("yyyy-MM-dd HH:mm:ss"):"") %></td>
                <td><%= item.OnlineState.GetName() %></td>
                <td><%=Html.ActionLink("查看明细", "AccountDetail", Url.Route(new { Serch = new { LoginName = item.ChildName, Type = UserAccountDetailType.Play },returnUrl=Request.RawUrl }, new { act = "AllChild", cont = "Surrogate" }), null)%></td>
                <td><%=Html.ActionLink("账变明细", "AccountDetail", Url.Route(new { Serch = new { LoginName = item.ChildName }, returnUrl = Request.RawUrl }, new { act = "AllChild", cont = "Surrogate" }), null)%></td>
                <td class='td_UserState_<%=i %>'><%=item.State.GetName() %></td>
                <td>
                    <%
                        if (Model.UserID != Model.LoginUserID) ;
                      else if(item.State==UserState.Locked_Manage)
                      {
                          var free = new { @class = "a_blue A_Free_" + i, onClick = "return Free('" + urlFree + "','" + item.Uid + "'," + i + ");" };
                          var _lock = new { @class = "a_blue A_Lock_" + i, style = "display:none;", onClick = "return Lock('" + urlLock + "','" + item.Uid + "'," + i + ");" };
                          %>
                        <%=Html.ActionLink("解除锁定", "", "",free)%>
                        <%=Html.ActionLink("锁定", "", "", _lock)%>
                    <%}
                      else if (Model.NoAccountChilds.Select(p => p.Uid).Contains(item.Uid))
                      {
                          var free = new { @class = "a_blue A_Free_" + i, style = "display:none;", onClick = "return Free('" + urlFree + "','" + item.Uid + "'," + i + ");" };
                          var _lock = new { @class = "a_blue A_Lock_" + i, onClick = "return Lock('" + urlLock + "','" + item.Uid + "'," + i + ");" };
                          %>
                        <%=Html.ActionLink("解除锁定", "", "",free)%>
                        <%=Html.ActionLink("锁定", "", "",_lock )%>
                    <%} %>
                </td>
            </tr>
        <%
	    } %>
        <tr>
            <td colspan='10' align="center">
                <%--<%=Html.Pager(Model.PageInfo.CurrPage, Model.PageInfo.PageCount, Model.PageInfo.SunCount, Url.Content("~/Surrogate/AllChild?userID=" + Model.UserID + ViewData["url"] + "&page="))%>--%>
                <%=Html.Pager(Model.PageInfo.CurrPage, Model.PageInfo.PageCount, Model.PageInfo.SunCount, "PageInfo.CurrPage", Url.Route(new { userID = Model.UserID, Model.Where }), "PageInfo.PageCount")%>
            </td>
        </tr>
    </table>
</div>
</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="StyleAndScript" runat="server">
    <style type="text/css">
        .lbl{ float:left; text-align:right; width:130px;}
        h4{ margin:8px 0px; font-weight:200; font-size:12px;}
    </style>
    <script type="text/javascript">
        function Lock(url,id,index) {
            getJSON(url, { uid: id }, function (result) {
                if (result.count > 0) {
                    $(".A_Free_" + index).show();
                    $(".A_Lock_"+index).hide();
                    $(".AllChild .td_UserState_" + index).text("代理锁定");
                }
                if (result.msg.length)
                    alert(result.msg);
            });
            return false;
        }
        function Free(url,id,index) {
            getJSON(url, { uid: id }, function (result) {
                if (result.count > 0) {
                    $(".A_Lock_" + index).show();
                    $(".A_Free_"+index).hide();
                    $(".AllChild .td_UserState_" + index).text("冻结");
                }
                if (result.msg.length)
                    alert(result.msg);
            });
            return false;
        }
    </script>
</asp:Content>